package com.rise.remi.world;

import com.rise.remi.core.Global;
import com.rise.remi.items.Item;
import com.rise.remi.layer.TiledLayer;
import java.awt.Graphics;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import lombok.Getter;

/**
 *
 * @author remi
 */
public final class World {

    private @Getter TiledLayer worldLayer;
    private @Getter TiledLayer objectsLayer;
    private @Getter TiledLayer nullLayer;
    private @Getter ArrayList<Item> items = new ArrayList<>();

    public World(int tileWidth, int tileHeight, int width, int height) {
        try {
            nullLayer = new TiledLayer(ImageIO.read(getClass().getResourceAsStream(Global.pathToTheTiles)), tileWidth, tileHeight, width, height);
            worldLayer = new TiledLayer(ImageIO.read(getClass().getResourceAsStream(Global.pathToTheTiles)), tileWidth, tileHeight, width, height);
            objectsLayer = new TiledLayer(ImageIO.read(getClass().getResourceAsStream(Global.pathToTheTiles)), tileWidth, tileHeight, width, height);
        } catch (IOException ex) {
        }
    }

    public void draw(Graphics g) {
        final int blocksX = worldLayer.getBlocksX();
        final int blocksY = worldLayer.getBlocksY();
        nullLayer.setBlocksX(blocksX);
        nullLayer.setBlocksY(blocksY);
        objectsLayer.setBlocksX(blocksX);
        objectsLayer.setBlocksY(blocksY);

        worldLayer.paintLayer(g);
        objectsLayer.paintLayer(g);
    }

}
